package app;

import com.activeandroid.ActiveAndroid;
import com.bmob.BmobConfiguration;
import com.bmob.BmobPro;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.umeng.socialize.PlatformConfig;

/*******************************************************************************
 * Copyright 2011-2013 Sergey Tarasevich
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

import android.app.Application;
import android.content.Context;
import cn.bmob.v3.Bmob;
import cn.jpush.android.api.JPushInterface;

public class BaseApp extends Application {

	/**
	 * Bmob SDK初始化建议放在启动页
	 * 注意：替换自己的ID
	 */
	public static String APPID = "12ca893c99bc5f765825df4078ff318b";
	/*
	 * 微信APPID
	 */
	private static final String APP_Wx_ID="wx1f5d648e92c5f914";//
/**
 * 环信私信
 */
	public static Context applicationContext;
    public static DemoHXSDKHelper hxSDKHelper = new DemoHXSDKHelper();
    
	public static IWXAPI api;
	public void onCreate() {
		super.onCreate();
		ActiveAndroid.initialize(this);
		initImageLoader(getApplicationContext());
		initConfig(getApplicationContext());
		Bmob.initialize(getApplicationContext(),APPID);
	
		 JPushInterface.setDebugMode(true); 	// 设置开启日志,发布时请关闭日志
         JPushInterface.init(this);     		// 初始化极光 JPush
		
		
		//注册微信
		api = WXAPIFactory.createWXAPI(this,APP_Wx_ID,true); 
		api.registerApp(APP_Wx_ID);
		
		
		
		
		 hxSDKHelper.onInit(this);//环信私信
		/**
		 * 个推推送消息
		 */
//		PushManager.getInstance().initialize(this.getApplicationContext());
		
//		SDKInitializer.initialize(this);
		// JPushInterface.setDebugMode(true); // 璁剧疆锟�?鍚棩锟�?,鍙戝竷鏃惰鍏抽棴鏃ュ織
		// JPushInterface.init(this); // 鍒濆锟�? JPush
		
		
		/**
		 * 友盟分享
		 */
		//微信    wx12342956d1cab4f9,a5ae111de7d9ea137e88a5e02c07c94d
//        PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
          PlatformConfig.setWeixin("wx1f5d648e92c5f914", "29cd1ebfe2e85a8a5e4676026b222604");
        //豆瓣RENREN平台目前只能在服务器端配置
        //新浪微博
//        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad");
          PlatformConfig.setSinaWeibo("1146225536", "9ceb6f8b96c5a84c04e3a72f082b43a9");
        //易信
        PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
//        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi", "MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
        PlatformConfig.setAlipay("2015111700822536");
        PlatformConfig.setLaiwang("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e");
        PlatformConfig.setPinterest("1439206");

	}

	 /**
     * 环信获取当前登陆用户名
     *
     * @return
     */
    public static String getUserName() {
        return hxSDKHelper.getHXId();
    }

	/**
	 * 初始化文件配置
	 * @param context
	 */
	public static void initConfig(Context context) {
		BmobConfiguration config = new BmobConfiguration.Builder(context).customExternalCacheDir("Smile").build();
		BmobPro.getInstance(context).initConfig(config);
	}
	

	// @Override
	// public void onTerminate() {
	// super.onTerminate();
	// ActiveAndroid.dispose();
	// }

	public static void initImageLoader(Context context) {
		// This configuration tuning is custom. You can tune every option, you
		// may tune some of them,
		// or you can create default configuration by
		// ImageLoaderConfiguration.createDefault(this);
		// method.
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				context).threadPriority(Thread.NORM_PRIORITY - 2)
				.denyCacheImageMultipleSizesInMemory()
				.diskCacheFileNameGenerator(new Md5FileNameGenerator())
				.diskCacheSize(50 * 1024 * 1024)
				// 50 Mb
				.tasksProcessingOrder(QueueProcessingType.LIFO)
				// .writeDebugLogs() // Remove for release app
				.build();
		// Initialize ImageLoader with configuration.
		ImageLoader.getInstance().init(config);
	}
}